package com.example.framework.base;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public abstract class BaseFragment extends Fragment
{

      protected Context mContext;
      
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
            super.onCreate(savedInstanceState);
            mContext = getActivity();
      }
      
      
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
            return initView();
      }
      
      /**
       * 强制子类重写，实现子类特有的ui
       *
       * @return
       */
      protected abstract View initView();
      
      @Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState)
      {
            super.onActivityCreated(savedInstanceState);
            
            initData();
      }
      
      /**
       * 当孩子需要初始化数据，或者联网请求绑定数据，展示数据的 等等可以重写该方法
       */
      protected void initData()
      {
      
      }
}
